// 删除数据

import type { Datum, DatuRentBuilding, EnterpriseDetail, RentParams } from "@/types/enterprise"
import service, { request } from "@/utils/reuqest"


export  const delEnterpriseAPI=(id:number)=>{
    return  request<EnterpriseDetail>(`/park/enterprise/${id}`, 'DELETE')
}


//可租赁楼宇列表
export const  getRentBuildListAPI=()=>{
    return   request<DatuRentBuilding[]>(`/park/rent/building`)
    
}

//给企业添加合同
export  const createRentAPI=(data:RentParams)=>{
    return request('/park/enterprise/rent', 'POST' ,data)
}


// 获取企业合同列表

export  const  getRentListAPI=(id:number)=>{

    return   request<Datum[]>(`park/enterprise/rent/${id}`)
}

// 退租合同
export const outRentAPI = (rentId: string)=> {
    return request(`/park/enterprise/rent/${rentId}`, 'PUT')
  }

//   删除合同
export const delRentAPI = (rentId: string)=> {
    return request(`/park/enterprise/rent/${rentId}`, 'DELETE')
  }

//   获取合同详情
export const getEnterpriseDetailAPI = (id: string) => {
    return request<EnterpriseDetail>(`/park/enterprise/${id}`)
  }

//   下载合同文件

export const  downloadContract =(id:number)=>{
    // 普通写法
    
    // 第二个参数指定后端返回值类型 blob
    return  service.request<null, Blob>({
         method: 'GET',
         url: `/download/${id}`,
         responseType: 'blob'
    })
}